package com.yc.dao;

import com.yc.bean.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface AccountDao {

    @Update("update account set balance=balance+#{balance} where accountid=#{accountid}")
    public void updateAccount(Account account);

    @Select("select * from account where accountid=#{accountid}")
    public Account findAccount(int accountid);

    @Insert("insert into account values (#{accountid},#{balance},#{name}," +
            "#{pwd},#{regtime},#{email})")
    @Options(useGeneratedKeys = true, keyProperty = "accountid", keyColumn = "accountid")
    public int insert(Account account);

    @Select("select count(*) from account where name=#{name}")
    public int countByName(String name);

}
